package team.sun.sss.dao.staff;


import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;
import team.sun.sss.pojo.staff.Staff;

import java.util.List;

@Mapper
@Repository
public interface StaffDao {
    @Select("select * from staff where sta_num=#{staNum}")
    Staff getStaffById(String staNum);

    @Select("select * from staff")
    List<Staff> getStaffList();

    @Insert("insert into staff(" +
            "sta_num," +
            "sta_name," +
            "sta_email," +
            "sta_sex," +
            "sta_nation," +
            "sta_college," +
            "sta_province," +
            "sta_political_outlook," +
            "sta_sort," +
            "sta_education_background," +
            "sta_id_card," +
            "sta_degree," +
            "sta_birthday," +
            "sta_work_type," +
            "sta_marriage," +
            "sta_first_work_date," +
            "sta_work_title," +
            "sta_phone_num," +
            "sta_postal_code," +
            "sta_work_state," +
            "sta_counsellor_time," +
            "sta_wechat," +
            "sta_qq_num," +
            "user_state)" +
            " values(" +
            "#{staNum}," +
            "#{staName}," +
            "#{staEmail}," +
            "#{staSex}," +
            "#{staNation}," +
            "#{staCollege}," +
            "#{staProvince}," +
            "#{staPoliticalOutlook}," +
            "#{staSort}," +
            "#{staEducationBackground}," +
            "#{staIdCard}," +
            "#{staDegree}," +
            "#{staBirthday}," +
            "#{staWorkType}," +
            "#{staMarriage}," +
            "#{staFirstWorkDate}," +
            "#{staWorkTitle}," +
            "#{staPhoneNum}," +
            "#{staPostalCode}," +
            "#{staWorkState}," +
            "#{staCounsellorTime}," +
            "#{staWechat}," +
            "#{staQqNum}," +
            "#{userState})")
    int addStaff(Staff staff);

    @Update("update staff set user_state = 1 where sta_num=#{userId}")
    int userStop(String userId);

    @Update("update staff set user_state = 0 where sta_num=#{userId}")
    int userStart(String userId);

    @Update("update staff set " +
            "sta_name=#{staName}," +
            "sta_email=#{staEmail}," +
            "sta_sex=#{staSex}," +
            "sta_nation=#{staNation}," +
            "sta_college=#{staCollege}," +
            "sta_province=#{staProvince}," +
            "sta_political_outlook=#{staPoliticalOutlook}," +
            "sta_sort=#{staSort}," +
            "sta_education_background=#{staEducationBackground}," +
            "sta_id_card=#{staIdCard}," +
            "sta_degree=#{staDegree}," +
            "sta_birthday=#{staBirthday}," +
            "sta_work_type=#{staWorkType}," +
            "sta_marriage=#{staMarriage}," +
            "sta_first_work_date=#{staFirstWorkDate}," +
            "sta_work_title=#{staWorkTitle}," +
            "sta_phone_num=#{staPhoneNum}," +
            "sta_postal_code=#{staPostalCode}," +
            "sta_work_state=#{staWorkState}," +
            "sta_counsellor_time=#{staCounsellorTime}," +
            "sta_wechat=#{staWechat}," +
            "sta_qq_num=#{staQqNum}," +
            "user_state=#{userState} where sta_num=#{staNum}")
    int updateStaff(Staff staff);

    @Select("select sta_name from staff where sta_num=#{staNum}")
    Staff getStaffByName(int staNum);

    @Select("select sta_name from staff where sta_num=#{staNum}")
    String getStaName(int staNum);

    @Select("select sta_num from staff where sta_name=#{staName}")
    int getStaIdOfName(String staName);
}
